Skip to content

fix: correct OAuth service health check URL#3185

Merged
Umang01-hash merged 5 commits intogofr-dev:developmentfrom
coolwednesday:fix/oauth-health-check-3179-clean
Mar 24, 2026
Merged

fix: correct OAuth service health check URL#3185
Umang01-hash merged 5 commits intogofr-dev:developmentfrom
coolwednesday:fix/oauth-health-check-3179-clean

Conversation

@coolwednesday
Copy link
Copy Markdown
Member

@coolwednesday coolwednesday commented Mar 20, 2026

Summary

  • EnableOAuth passed the full JWKS endpoint URL (e.g., https://auth.example.com/.well-known/jwks.json) as the HTTP service address, causing health checks to hit https://auth.example.com/.well-known/jwks.json/.well-known/alive — an invalid URL that always fails and degrades application health status.
  • Fix: parse the JWKS endpoint URL to extract the base URL (scheme://host) for HTTP service registration, and pass the JWKS path separately via OauthConfigs.Path (already supported but never populated).
  • Health checks now correctly hit https://auth.example.com/.well-known/alive
  • JWKS fetching continues to work via the existing Path field in OauthConfigs

Test plan

coolwednesday and others added 5 commits March 20, 2026 15:29
EnableOAuth was passing the full JWKS endpoint URL as the HTTP service
address, causing the health check to append /.well-known/alive to the
JWKS path instead of the host root. Parse the URL to separate base URL
from JWKS path, so health checks hit the correct endpoint.

Fixes gofr-dev#3179
Adds TestEnableOAuth_HealthCheckEndpoint that passes a full JWKS URL
with a path and asserts the health check hits /.well-known/alive on the
host root, not on the JWKS path.
The service layer constructs URLs as h.url + "/" + path, so passing
a path with a leading slash creates a double-slash (e.g.,
http://host//.well-known/jwks.json). Strip the leading slash to match
the convention used by HealthCheck.

Also strengthens the test to verify JWKS fetching returns 200, ensuring
the path is correctly constructed without double slashes.
url.Parse is very permissive and rarely returns errors. Inputs like
empty strings, relative paths, or non-HTTP schemes would silently
produce a bogus base URL, misconfiguring OAuth without any error.

Add explicit validation that scheme is http/https and host is non-empty.
Add TestEnableOAuth_InvalidEndpoints covering these edge cases.
@Umang01-hash Umang01-hash merged commit a6f8a9d into gofr-dev:development Mar 24, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect service health check status when using EnableOAuth

2 participants